﻿
//var musiclist = new Array();
//var curmusicindex = 0;

$(document).ready(loadok);

function loadok(){    
    //var hasVideo = !!(document.createElement('audio').canPlayType);
    
    radioon = false;
	    
	    $("#radio_on_off").click(radio_on_off);

	    $("#nextmusic").click(nextmusic);
	    
	    usercontent = $("#user").html();
	  if(usercontent.indexOf("login") < 0)
	  {
	  	$("#logouturl").attr("href",appurlprefix+"/user/logout");
	  	
	  	//annotionpart
	    for(var i = 1;i < 10;i++)
	    {
	        var idp = "#p"+i;
	        $(idp).click(onannoation);
	        var ida = "#a"+i;
	        $(ida).click(onannoation);
	        var idd = "#d"+i;
	        $(idd).click(onannoation);
	    }
	    
	    /*******************error process part*****************/
	    //audio error
	    $("#uploaddlg").dialog({
	    	autoOpen:false,
	    	width:600,
	    	button:{
	    		"Cancel":function(){
	    			$(this).dialog("close");
	    		}
	    	}
	    });
	    $("#linkerror").click(showupload);
	    
	    $("#basicinfoerrordlg").dialog({
	    	autoOpen:false,
	    	width:600,
	    	button:{
	    		"Cancel":function(){
	    			$(this).dialog("close");
	    		}
	    	}
	    });
	    $("#id3error").click(showbasicinfoerror);
	    
	    $("#lyricerrordlg").dialog({
	    	autoOpen:false,
	    	width:600,
	    	button:{
	    		"Cancel":function(){
	    			$(this).dialog("close");
	    		}
	    	}
	    });
	    
	    $("#lyricerror").click(showlyricerror);
	    
	     $("#showmodifydlg").dialog({
	    	autoOpen:false,
	    	width:600,
	    	button:{
	    		"Cancel":function(){
	    			$(this).dialog("close");
	    		}
	    	}
	    });
	    
	    //show the modify info of one music
	    $("#showmodify").click(showmodifyofmusic);
	    $("#faq").attr("href",appurlprefix+"/tools/faq");
	    $("#tools").attr("href",appurlprefix+"/tools");
	    $("#logouturl").attr("href",appurlprefix+"/user/logout");
	  }
	  else
		{
	  		//set the login and registerlink
	  	$("#loginurl").attr("href",appurlprefix+"/user/login");
	  	$("#regurl").attr("href",appurlprefix+"/user/reg");
	  }
	    
		var support = !!document.createElement('video').canPlayType;
    if(support)
    {
	    $("#audioele").attr("onended","nextmusic()");
	    $("#audioele").attr("ontimeupdate","musictimeupdate()");
	  }
	  else
	  {
	  	
	  	$("#musicplayer").html("<p>To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed. </p><p><a href='http://172.31.202.91/static/flash10.exe'></a>Download</p>");

			<!-- For version detection, set to min. required Flash Player version, or 0 (or 0.0.0), for no version detection. --> 
      var swfVersionStr = "10.0.0";
      <!-- To use express install, set to playerProductInstall.swf, otherwise the empty string. -->
      var xiSwfUrlStr = "/static/swf/playerProductInstall.swf";
      var flashvars = {};
      var params = {};
      params.quality = "high";
      params.bgcolor = "#ffffff";
      params.allowscriptaccess = "sameDomain";
      params.allowfullscreen = "true";
      var attributes = {};
      attributes.id = "musicplayer";
      attributes.name = "test4";
      attributes.align = "middle";
      swfobject.embedSWF(
          "/static/swf/test4.swf?musicurl=nomusic",  "musicplayer", 
          "392", "164", 
          swfVersionStr, xiSwfUrlStr, 
          flashvars, params, attributes);
      swfobject.createCSS("#musicplayer", "display:block;text-align:left;");
	  }
}
